package myMapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import myClass.car;

public interface carMapper {
//获取购物车中指定用户的指定相同商品
	@Select("SELECT * FROM tb_car WHERE username=#{username} AND product_id=#{product_id} AND size=#{size}")
	public List<car> selectAllCarByUsernameSP(@Param("username")String username,@Param("product_id")int product_id,@Param("size")String size);
//	向购物车中插入商品
	@Insert("INSERT INTO tb_car VALUES(#{username},#{product_id},#{num},#{size})")
	public void insertIntoCar(@Param("username")String username,@Param("product_id")int product_id,@Param("num")int num,@Param("size")String size);
//更新购物车指定商品尺寸的数量
	@Update("UPDATE tb_car SET num+=#{num} WHERE product_id=#{product_id} AND size=#{size}")
//	@Delete("DELETE FROM tb_car")
	public void updateCarNum(@Param("num")int num,@Param("product_id")int product_id,@Param("size")String size);

}
